<template>
    <div>
        <el-form label-width="100px" ref="AddQualification_refs" :model="Qualification">
            <el-row>
                <el-col :span="10" :offset="1">
                    <el-form-item label="资质类型" prop="Level">
                        <el-select v-model="Qualification.Level" style="width: 100%">
                            <el-option v-for="v in AllTypes" :label="v.name" :value="v.value"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="10" :offset="1">
                    <el-form-item label="资质名称" prop="EnterpriseName">
                        <el-input v-model="Qualification.EnterpriseName" placeholder="资质名称"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="10" :offset="1">
                    <el-form-item label="资质编号" prop="EnterpriseNumber">
                        <el-input v-model="Qualification.EnterpriseNumber" placeholder="资质编号"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="10" :offset="1">
                    <el-form-item label="发证机关" prop="CertificationAuthority">
                        <el-input v-model="Qualification.CertificationAuthority" placeholder="发证机关"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="10" :offset="1">
                    <el-form-item label="发证日期" prop="ReleaseDate">
                        <el-date-picker style="width: 100%" placeholder="发证日期"
                                        type="date"
                                        format="yyyy-MM-dd"
                                        v-model="Qualification.ReleaseDate"></el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="10" :offset="1">
                    <el-form-item label="有效日期" prop="EffectiveDate">
                        <el-input v-model="Qualification.EffectiveDate" placeholder="有效日期"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="10" :offset="1">
                    <el-form-item label="所属权人" prop="CustodianId">
                        <el-input v-model="Qualification.CustodianId" placeholder="所属权人"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="10" :offset="1">
                    <el-form-item label="备注" prop="Remark">
                        <el-input v-model="Qualification.Remark" placeholder="备注"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-divider content-position="left">上传图片信息</el-divider>

            <el-row>
                <el-col :span="22" :offset="1">
                    <UploadFileF ref="Add_Qualification" style="width: 300px"
                                 :multiple="true"
                                 :another-data="AnotherData"
                                 :showfilelist="true"
                                 :upshow="false"
                                 content="文件上传"
                                 btnsize="medium"></UploadFileF>
                    <!--                    <el-table stripe :data="imageTableData">-->
                    <!--                        <el-table-column label="文件名" show-overflow-tooltip prop="name" align="center"></el-table-column>-->
                    <!--                        <el-table-column label="大小" show-overflow-tooltip prop="size" align="center"></el-table-column>-->
                    <!--                        <el-table-column label="状态" show-overflow-tooltip align="center">-->
                    <!--                            <template>-->
                    <!--                                <label>等待上传</label>-->
                    <!--                            </template>-->
                    <!--                        </el-table-column>-->
                    <!--                        <el-table-column label="操作" align="center">-->
                    <!--                            <template slot-scope="slot">-->
                    <!--                                <el-button type="danger" size="mini" >删除</el-button>-->
                    <!--                            </template>-->
                    <!--                        </el-table-column>-->
                    <!--                    </el-table>-->
                </el-col>
            </el-row>

            <el-row>
                <el-col align="center" style="margin-top: 10px">
                    <el-button type="primary" @click="AddQualification_event">立即提交</el-button>
                    <el-button type="info" @click="formresetFields_event">重置</el-button>
                </el-col>
            </el-row>

        </el-form>
    </div>
</template>

<script>
    import UploadFileF from "../../UploadFileF";

    export default {
        name: "AddQualification",
        props: {
            AllTypes: {
                type: Array,
                required: true,
            }
        },
        components: {
            UploadFileF
        },
        data() {
            return {
                //文件数据集合
                imageTableData: [],
                //资质实体数据
                Qualification: {
                    Level: '',
                    EnterpriseName: '',
                    EnterpriseNumber: '',
                    CertificationAuthority: '',
                    ReleaseDate: '',
                    EffectiveDate: '',
                    CustodianId: '',
                    Remark: '',
                },
                AnotherData: {
                    FileType: 128,
                    id: 1,
                    Type: 0,
                    Single: true,
                },
            }
        },
        methods: {
            //重置表格
            formresetFields_event() {
                this.$refs['AddQualification_refs'].resetFields()
            },
            // 添加新产品
            AddQualification_event() {
                let loadding = this.openLoading();
                this.$http.post('Qualification/AddQualificationsDB', this.Qualification).then(res => {
                    loadding.close();
                    if (res.data.flag) {
                        this.$message.success('添加成功!')
                        //region 文件上传
                        this.AnotherData.Type = res.data.Id
                        if (this.$refs['Add_Qualification'].fileList.length > 0) {
                            this.$refs['Add_Qualification'].submitUpload()
                        }
                        //endregion
                        this.$parent.$parent.AddQualification_dialog = false
                        this.$parent.$parent.formdata()
                        this.formresetFields_event()
                    } else {
                        this.$message.warning('添加失败,请重试!')
                    }
                })
            }
        }
    }
</script>

<style scoped>

</style>
